package javabase.schoolwork.day5_31;

/**
 * @author fance
 * @date 2018/5/31 21:30
 */
public class Person {
    private int age;
    private String telephone;

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws Exception {
        if (age > 0 && age <= 100) {
            this.age = age;
        } else {
            throw new Exception("年龄必须在1-100之间");
        }
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) throws Exception {
        if (telephone.length() == 11) {
            this.telephone = telephone;
        } else {
            throw new Exception("电话号码必须是11位");
        }
    }
}
